import {SetMetadata} from "@nestjs/common";
import {APP_GUARD} from "@nestjs/core";
import {JwtAuthGuard} from "./JwtAuthGuard";
import {RoleEnum} from "../../common/enum/RoleEnum";
import {RoleGuard} from "./RoleGuard";

// 全局jwt认证provider！
export const JwtAuthGuardProvider = {
    provide: APP_GUARD,
    useClass: JwtAuthGuard
}

// 自定义 放行注解
export const SKIP_AUTH_KEY = 'skip_auth';
export const SkipAuth = () => SetMetadata(SKIP_AUTH_KEY, true);

// 全局角色权限校验
export const RoleGuardProvider = {
    provide: APP_GUARD,
    useClass: RoleGuard
}

// 权限校验
export const ROlES_KEY = "roles";
export const NeedRoles = (...roles: RoleEnum[]) => SetMetadata(ROlES_KEY, roles)

export class GlobalGuardProvider {}
